<?php
/**
 * Description of MessageHelper
 *
 * help to generate app messages
 *
 * @author ben
 */
class MessageHelper {
    public static $_instance=null;
    public $msg="";

    public static function getInstance() {
        $class = __CLASS__;
        if(is_null(self::$_instance)) {
            self::$_instance = new $class();
        }
        return self::$_instance;
    }

    public function __construct()			// construct method
    {
        ;
    }

    /*
     * return err message
     * @param - $msgPattern string,
     * @param - $opResultData  array()
     * 
     */
    public function getMsgOfMinusOrderItemConsumeGoods($opResultData, $msgPattern="%s", $splitter="<br/>")
    {
        if(count($opResultData["items"])>0)
        {
            foreach($opResultData["items"] as $item)
            {
                if($item['error'])
                {
                    $this->msg .= sprintf($msgPattern, $item["goods_category_name"], $item["exist_number"], $item["consume_number"]).$splitter;
                }
            }
        }
        return $this->msg;
    }
}

